package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.ConvertUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.wechat.domain.Camp;
import com.ruoyi.wechat.domain.Collect;
import com.ruoyi.wechat.domain.Evaluate;
import com.ruoyi.wechat.domain.WxEvaluate;
import com.ruoyi.wechat.service.ICollectService;
import com.ruoyi.wechat.service.IEvaluateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>ClassName : WxEvaluateController</p>
 * <p>Description : </p>
 *
 * @author 孙伟光
 * @version 1.0
 * @date 2024/7/30 15:47
 */
@Api(value = "微信小程序API-收藏管理", tags = {"微信小程序API-收藏管理"})
@RestController
@RequestMapping("/wechat/collect")
public class WxCollectController extends BaseController {

    @Autowired
    private ICollectService collectService;
    /**
     * 查询收藏列表
     */
    @ApiOperation(value = "收藏列表")
    @GetMapping("/list")
    public AjaxResult list()
    {
        String userId = SecurityUtils.getLoginUser().getUser().getNickName();
        List<Camp> list = collectService.selectCollectListByUserId(userId);
        return success(list);
    }


    /**
     * 点击收藏按钮
     */
    @ApiOperation(value = "点击收藏按钮")
    @Log(title = "点击收藏按钮", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Collect collect)
    {
        return success(collectService.colect(collect));
    }

}
